import request from '@/utils/request'
// 获取角色列表
export function getRoles (data) {
  return request({
    url: '/sys-system/roles/page',
    method: 'get',
    params: data
  })
}
//新增岗位
export function addPost (data) {
  return request({
    url: '/sys-user/post',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/** 更新岗位 */
export function savePost (data) {
  return request({
    url: '/sys-user/post',
    method: 'PUT',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
//更新岗位内角色
export function saveRoleGroup (data) {
  return request({
    url: '/sys-user/user_group',
    method: 'PUT',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

//获取岗位已配置角色
export function getRolesByGroup (data) {
  return request({
    url: '/sys-user/user_group/roles',
    method: 'get',
    params: data
  })
}

//获取岗位下用户
export function getRoleGroupUser (params) {
  return request({
    url: '/sys-user/post/users/page',
    method: 'get',
    params: {
      ...params
    },
  })
}
//根据id删除岗位
export function deletePost (id) {
  return request({
    url: '/sys-user/post',
    method: 'DELETE',
    params: {
      id: id
    },
  })
}
//获取岗位分页
export function getPost (params) {
  return request({
    url: '/sys-user/post/page',
    method: 'get',
    params: params
  })
}
//获取所有的岗位
export function getAllPost () {
  return request({
    url: '/sys-user/posts',
    method: 'get',

  })
}
//更新岗位
export function updatePost (data) {
  return request({
    url: '/sys-user/post',
    method: 'put',
    data: data,
  })
}
//更新岗位所属门户
export function updatePortal (data) {
  return request({
    url: '/sys-user/portal',
    method: 'put',
    data: data
  })
}